<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加印花</title>
<script language="javascript">
    $(document).ready(function(){
        $("#saveForm").click(function () {
            var param = $('form').serialize();
            $.post("/productprint/addproductprint",{param: param}, function (data) {
                if (data.code) {
                    alert(data.msg);
                    location.href = '/productprint/showlist'
                } else {
                    alert(data.msg);
                    return false;
                }
            }, "json");
        });
    });
    function getSku()
    {
        var sku = $("#goods_sku").val();
        if(sku){
            $.post("/productprint/ajaxbutton",{"op":"searchProductPrint","goods_id": sku},function(data){
                if(data.code)
                {
                    var url = 'http://192.168.1.66/'+data.local_url;
                    $("#showimg").html('<img src='+url+'>');
                    $('#goods_name').val(data.goods_name);
                }else{
                    $("#skuerr").html(data.msg).css('color','red');
                    $("#showimg").html('');
                    $('#thumb_imgs').val('');
                    $('#goods_name').val('');
                }
            },"json");
        }else{
            $("#skuerr").html('没有输入任何数据!').css('color','red');
        }
    }
    function checkDecimal(obj,flag) {
        if(flag == 1){
            var decimalReg=/^\d{0,9}\)?$/; //只能输入数字
        }
        if(flag == 2){
            var decimalReg = /^\d+(?=\.{0,1}\d+$|$)/; //可以输入数字或小数点
        }
        if(obj.value!=""&&decimalReg.test(obj.value)){
        }else {
            if (obj.value != "") {
                obj.value = 0
            }
        }
    }
</script>
<body class="withvernav">
<div class="bodywrapper"> {{include file='/public/leftmenu.tpl'}}
    <div class="centercontent">
        <div class="pageheader notab">
            <h1 class="pagetitle">添加印花</h1>
        </div>
        <!--pageheader-->
        <div id="contentwrapper" class="contentwrapper">
            <div id="basicform" class="subcontent">
                <form class="stdform stdform2"  id="otherForm" method="post" action="/productprint/addproductprint" enctype="multipart/form-data" >
                    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
                    </table>
                    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
                        <tbody>
                        <tr>
                            <td class="head1"></td>
                            <td class="head0">
                               <span id="showimg"></span>
                                <input type="hidden" name="thumb_imgs" value="" id="thumb_imgs">
                            </td>
                            <td class="head1"></td>
                            <td class="head0"></td>
                        </tr>
                        <tr>
                            <td class="head1">商品编号</td>
                            <td class="head0">
                                <input type="text" name="goods_sku" id="goods_sku" class="width400" value="{{$goods.goods_sku}}">
                                <br/>
                                <span id="skuerr"></span>
                            </td>
                            <td class="head1"><button type="button" class="btn btn-primary"  onclick="getSku()">搜索</button></td>
                            <td class="head0"></td>
                        </tr>
                        <tr>
                            <td class="head1">商品名称</td>
                            <td class="head0"><input type="text" name="goods_name" id="goods_name" class="width400" value="{{$goods.goods_name}}" required></td>
                            <td class="head1"></td>
                            <td class="head0"></td>
                        </tr>
                        <tr>
                            <!--
                            <td class="head1">订单编号</td>
                            <td class="head0"><input type="text" name="en_goods_name" class="width400" value="{{$goods.en_goods_name}}"></td>
                            -->
                            <td class="head1">外发工厂</td>
                            <td colspan="3" class="head0">
                                <select class="selectCss2" name="factorys" id="factorys">
                                    <option value="">请选择</option>
                                    {{foreach from=$factorys item=res key=key}}
                                        <option value="{{$res}}"> {{$res}} </option>
                                    {{/foreach}}
                                </select></td>
                            </td>
                        </tr>
                        <tr>
                            <td class="head1">印花数量</td>
                            <td class="head0"><input type="text" name="print_number" class="width100" value="" onblur="checkDecimal(this,1)"></td>
                            <td class="head0" width="120">绣花数量</td>
                            <td class="head1"><input type="text" name="embroider_number" class="width100" value="" onblur="checkDecimal(this,1)"></td>
                        </tr>
                        <tr>
                            <td class="head1">印花价格</td>
                            <td class="head0"><input type="text" name="print_price" class="width100" value="" onblur="checkDecimal(this,2)"></td>
                            <td class="head0" width="120">绣花价格</td>
                            <td class="head1"><input type="text" name="embroider_price" class="width100" value="" onblur="checkDecimal(this,2)"></td>
                        </tr>
                        <tr>
                            <td class="head1">主料价格</td>
                            <td class="head0"><input type="text" name="master_price" class="width100" value="" onblur="checkDecimal(this,2)"></td>
                            <td class="head0" width="120">辅料价格</td>
                            <td class="head1"><input type="text" name="lesser_price" class="width100" value="" onblur="checkDecimal(this,2)"></td>
                        </tr>
                        <tr>
                            <td class="head1">完成工期</td>
                            <td class="head0" width="30%"><input type="text" name="finish_day" class="width100" value=""  onblur="checkDecimal(this,1)" >&nbsp;(天)</td>
                        </tr>
                        <tr>
                            <td class="head1">备注信息</td>
                            <td class="head0" colspan="3">
                                <textarea name="memo" cols="10" rows="6"></textarea>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
                        <thead>
                        <tr>
                            <td><button type="button" id ="saveForm" class="btn btn-primary" >确认保存</button>
                            </td>
                        </tr>
                        </thead>
                    </table>
                </form>
                <br />
            </div>
            <!--subcontent-->

            <!--subcontent-->

        </div>
        <!--contentwrapper-->

    </div>
    <!-- centercontent -->

</div>
<!--bodywrapper-->

</body>
</html>